<template>
  <view class="container">
    <!-- 轮播图组件区域 -->
    <view class="Swiper_container">
      <u-swiper height="320" :list="SwiperList">
      </u-swiper>
    </view>
    <!--头像区域-->
    <app-userHead :user="user">
    </app-userHead>
    <!-- 管理区域 -->
    <view class="adm_container">
      <app-gong v-for="(item,index) in admList"
        :key="index" :info="item">
        <navigator class="more"
          :url="'/pages/tools/management?state='+index">
          {{item.more}}
        </navigator>
      </app-gong>
      <!--信息统计-->
      <!-- <Statistics></Statistics>-->
    </view>
  </view>
</template>

<script>
import appGong from '@/components/app-gong'
import appUserHead from '@/components/app-userHead'
import Statistics from './Statistics.vue'
export default {
  components: {
    Statistics,
    appUserHead,
    appGong
  },
  data() {
    return {
      user: null,
      // 轮播图
      SwiperList: [],
      active: 0, // 自定义轮播指示点
      // 管理区域
      admList: [
        {
          title: '日常工作', //所有人都显示
          more: ' ',
          children: [
            {
              img: '/static/workImg/u149.png',
              name: '考勤打卡',
              url: '/pages/index/punchtheclock'
            },
            {
              img: '/static/workImg/u139.png',
              name: '请假申请',
              url: '/pages/index/leave'
            },
            {
              img: '/static/workImg/u133.png',
              name: '销售报表',
              url: '/pages/sale/report_select'
            },
            {
              img: '/static/workImg/u136.png',
              name: '报销审批',
              url: '/pages/sale/expense_list'
            },
            {
              img: '/static/workImg/u139.png',
              name: '在售商品',
              url: '/pages/sale/my_product'
            }
          ]
        },
	    {
	      title: '信息统计', //所有人都显示
	      more: ' ',
	      children: [
	        {
	          img: '/static/workImg/u149.png',
	          name: '按订单',
	          url: '/pages/total/orderlist'
	        },
	        {
	          img: '/static/workImg/u139.png',
	          name: '按商品',
	          url: '/pages/total/prolist'
	        },
	        {
	          img: '/static/workImg/u133.png',
	          name: '按个人',
	          url: '/pages/total/userlist'
	        } ,
			{
			  img: '/static/workImg/u133.png',
			  name: '办公室审核',
			  url: '/pages/manage/ReportList'
			} 
	      ]
	    }
	  ]
    }
  },
  onLoad(e) {
    // uni.navigateTo({
    // 		url:"/pages/sale/draw/drawSelect"
    // 	})
    let userInfo = uni.getStorageSync('user_info')
    if (!userInfo) {
      uni.showToast({
        title: '未获取到用户信息,请重新加载小程序',
        icon: 'none',
        duration: 2000
      })
      uni.navigateTo({
      		url:"/pages/tools/tools"
      	})
	  //加跳转到登录页面或者刷新当前页面
    }

    let userbase = userInfo.userbase
    let busbasic = userInfo.busbasic
    this.user = userInfo
    if (!userbase) return
    if (userbase.fIsSale == 10) {
      this.admList.unshift(
        {
          title: '客户管理', //fIsSale=10 才显示
          more: ' ',
          children: [
            {
              img: '/static/workImg/u88.png',
              name: '我的任务',
              url: '/pages/index/taskList'
            },
            {
              img: '/static/workImg/u91.png',
              name: '拜访记录',
              url: '/pages/sale/visit_records'
              // url: "/pages/customer/visit"
            },
            {
              img: '/static/workImg/u94.png',
              name: '我的客户',
              url: '/pages/client/client',
              type: 'switchTab'
              // url: "/pages/customer/my"
            },
            {
              img: '/static/workImg/u97.png',
              name: '添加客户',
              url: '/pages/customer/add'
            }
          ]
        },
        {
          title: '订单管理', //fIsSale=10 才显示
          more: ' ',
          children: [
            {
              img: '/static/workImg/u97.png',
              name: '全部',
              type: 'switchTab',
              url: '/pages/order/order'
            },
            {
              img: '/static/workImg/u158.png',
              name: '待分配',
              type: 'switchTab',
              url: '/pages/order/order?state=1'
            },
			{
			  img: '/static/workImg/u158.png',
			  name: '待配送',
			  type: 'switchTab',
			  url: '/pages/order/order?state=2'
			},
            {
              img: '/static/workImg/u136.png',
              name: '待收款',
              type: 'switchTab',
              url: '/pages/order/order?state=3'
            },
            {
              img: '/static/workImg/u139.png',
              name: '未结清',
              type: 'switchTab',
              url: '/pages/order/order?state=4'
            },
            {
              img: '/static/workImg/u77.png',
              name: '已完成',
              type: 'switchTab',
              url: '/pages/order/order?state=5'
            }
          ]
        }
      )
    }
    if (userbase.fIsDriver == 10) {
      this.admList.push({
        title: '配送管理', //fIsDriver=10 才显示
        more: ' ',
        children: [
          {
            img: '/static/workImg/u158.png',
            name: '待领任务',
            url: '/pages/sale/FindTaskList'
          },
          {
            img: '/static/workImg/u149.png',
            name: '配送任务',
            url: '/pages/sale/Dctask/Dctask'
          },
          {
            img: '/static/workImg/u152.png',
            name: '领货单',
            url: '/pages/sale/draw/drawRecord?state=2'
          },
          {
            img: '/static/workImg/u155.png',
            name: '车上库存',
            url: '/pages/tools/carInventory/carInventory'
          },
           {
              img: '/static/workImg/u158.png',
              name: '回交报表',
              url: '/pages/driver/carreport'
            },
          {
            img: '/static/workImg/u161.png',
            name: '清点入库',
            url: '/pages/sale/draw/drawRecord?state=1'
          }
        ]
      })
    }
    if (userbase.fIsKeeper == 10) {
      this.admList.push({
        title: '仓库管理', //fIsKeeper==10 才显示
        more: ' ',
        children: [
          {
            img: '/static/workImg/u149.png',
            name: '商品入库',
            url: '/pages/stock/ProIn/Index'
          },
          {
            img: '/static/workImg/u139.png',
            name: '领货单审核',
            url: '/pages/stock/ProCha/Index?state=2'
          },
          {
            img: '/static/workImg/u133.png',
            name: '还库单审核',
            url: '/pages/stock/ProCha/Index?state=1'
          },
        //  {
          //  img: '/static/workImg/u136.png',
          //  name: '退换货审核',
          //  url: '/pages/stock/ProCha/Index?state=3'
         // },
         {
           img: '/static/workImg/u139.png',
             name: '地图测试',
             url: '/pages/stock/ProWar/Detail'
           },
		   
		  {
		    img: '/static/workImg/u139.png',
		    name: '公司资质',
		    url: '/pages/filepic/filelist'
		  }
        ]
      })
    }
    this.$axios('api/BusBanner/GetList', 'post').then(res => {
      this.SwiperList = res.Value.map(x => ({ image: this.urlimg + x.fPic }))
    })
    uni.setNavigationBarTitle({
      title: busbasic.fBusName
    })
  },
  onShareAppMessage() {},
  methods: {
    // 自定义轮播指示点事件
    CheageActive(e) {
      this.active = e.detail.current
    },

    Addskip(url) {
      uni.navigateTo({
        url
      })
    }
  }
}
</script>

<style lang="scss" scoped>
page {
  background-color: rgba(245, 245, 245, 1);
}

.container {
  position: relative;

  // 轮播图组件样式
  .Swiper_container {
    position: relative;
    margin-bottom: -40rpx;
    /deep/ .u-swiper-indicator {
      bottom: 20% !important;
    }
    image {
      width: 100%;
    }
  }

  //管理区域样式
  .adm_container {
    padding-left: 18rpx;
    .more {
      color: #0079fe;
    }
  }
}
</style>
